//
//  ToJsonObject.swift
//  Exchange
//
//  Created by rui on 2018/6/11.
//  Copyright © 2018年 common. All rights reserved.
//

import UIKit

protocol ToJsonObject {
    func toData() -> Data?
    var jsonObject: Any? {get}
}

extension ToJsonObject {
    
    var jsonObject: Any? {
        guard let data = self.toData(), let jsonObj = try? JSONSerialization.jsonObject(with: data, options: .mutableContainers) else {
            return nil
        }
        return jsonObj
    }
}




